package cn.itsource.ymcc.web.controller;

import cn.itsource.ymcc.domain.CourseDoc;
import cn.itsource.ymcc.query.CourseDocQuery;
import cn.itsource.ymcc.result.JsonResult;
import cn.itsource.ymcc.service.IESearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/es")
public class ESearchController {

    @Autowired
    private IESearchService eSearchService;
    @PostMapping("/save")
    public JsonResult save(@RequestBody List<CourseDoc> courseDoc){
        return eSearchService.save(courseDoc);
    }
    @PostMapping("/search")
    public JsonResult search(@RequestBody CourseDocQuery query){
        return eSearchService.search(query);
    }
    @PostMapping("/delete")
    public JsonResult delete(@RequestBody List<Long> courseIds){
        return eSearchService.delete(courseIds);
    }

    @GetMapping("/selectOneByCourseId/{courseId}")
    public JsonResult selectOneByCourseId(@PathVariable("courseId")Long courseId){
        return eSearchService.selectOneByCourseId(courseId);
    }

    @PostMapping("/getCourseInfo")
    public JsonResult getCourseInfo(@RequestBody List<Long> courseIds){
        return eSearchService.getCourseInfo(courseIds);
    }
    @PostMapping("/selectBatchById")
    public JsonResult selectBatchById(@RequestBody List<Long> courseIds){
        return eSearchService.selectbatchById(courseIds);
    }
}
